Title: SQL W3S (By-BKK) / 014 Select Top
Tags: Obsidian_to_Anki

Q: What does SELECT TOP do in SQL Server and MS Access?
A: Limits the number of rows returned by a query

Q: True/False: SELECT TOP works in all database systems
A: False

Q: Which clause does MySQL use to return limited results?
A: LIMIT

Q: How do you get the first three records in MySQL?
A: SELECT * FROM Customers LIMIT 3;

Q: Which clause does Oracle use to return limited results?
A: FETCH FIRST n ROWS ONLY

Q: How can you select top 3 records from a sorted result in SQL Server?
A: SELECT TOP 3 * FROM Customers ORDER BY column_name

Q: How do you get the first 50% of records in SQL Server?
A: SELECT TOP 50 PERCENT * FROM Customers;

Q: True/False: ORDER BY can be used with TOP, LIMIT, and FETCH FIRST
A: True

Q: What is Oracle's older syntax for limiting results?
A: ROWNUM

Q: Show an example using WHERE and TOP together in SQL Server
A: SELECT TOP 3 * FROM Customers WHERE Country='Germany';

Q: Show an example using WHERE and LIMIT together in MySQL
A: SELECT * FROM Customers WHERE Country='Germany' LIMIT 3;

Q: Show an example using WHERE and FETCH FIRST in Oracle
A: SELECT * FROM Customers WHERE Country='Germany' FETCH FIRST 3 ROWS ONLY;

Q: How do you keep only the table structure but remove all rows?
A: DELETE FROM table_name;

Q: Limits the number of rows returned by a query
A: What does SELECT TOP do in SQL Server and MS Access?

Q: LIMIT
A: Which clause does MySQL use to return limited results?

Q: FETCH FIRST n ROWS ONLY
A: Which clause does Oracle use to return limited results?

Q: ROWNUM
A: What is Oracle's older syntax for limiting results? Here are flashcards from the SQL SELECT TOP, LIMIT, FETCH FIRST ROWS ONLY, and ROWNUM concepts on W3Schools: